package com.nuanshui.heatedloan.controller.display.wallet;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.controller.BaseController;
import com.nuanshui.heatedloan.fund.facade.UserBindAccountService;
import com.nuanshui.heatedloan.fund.model.UserAccount;

/**
 * 用户绑定 帐号控制器
 * @ClassName: UserBindAccountController 
 * @author guohao
 * @date Jan 4, 2016 4:28:47 PM 
 *
 */
@RequestMapping("/user/bindAccount/")
@RestController
public class UserBindAccountController extends BaseController{

	@Reference(url=GlobalParam.FUND_DUBBO_SERVER,timeout=GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.FUND_DUBBO_SERVER_VERSION)
	private UserBindAccountService userBindAccountService;
	
	/**
	 * 绑定支付帐号
	 * @param 
	 * @author guohao
	 * @date Jan 4, 2016 4:29:53 PM
	 * @since 2.3.0
	 */
	
	@RequestMapping(value = "bindPayAccount",method = RequestMethod.POST)
	public String  bindPayAccount(UserAccount userAccount) {
		String userId = getCurrentUser().getId();
		userAccount.setUserId(userId);
		userBindAccountService.bindPayAccount(userAccount);
		return success();
	}
	/**
	 * 获取绑定的某种帐号
	 * @param 
	 * @author guohao
	 * @date Jan 4, 2016 5:31:41 PM
	 * @since 2.3.0
	 */
	
	@RequestMapping(value = "loadPayAccount",method = RequestMethod.POST)
	public String loadPayAccount(Integer accountType) {
		String userId = getCurrentUser().getId();
		return  success(userBindAccountService.loadUserPayAccount(userId, accountType));
		
	}	
}
